<?php
/**
 * 该示例主要为JPush Push API的调用示例
 * HTTP API文档:http://docs.jpush.io/server/rest_api_v3_push/
 * PHP API文档:https://github.com/jpush/jpush-api-php-client/blob/master/doc/api.md#push-api--构建推送pushpayload
 */
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
require_once("../src/JPush/JPush.php");

$br = '<br/>';
$app_key = 'e7d0bb62c1622601523c2443';
$master_secret = 'bcc98f903acd36a0ce054da9';

// 初始化
$client = new JPush($app_key, $master_secret);

// 简单推送示例
$result = $client->push()
    ->setPlatform('all')
    ->addAllAudience()
    ->setMessage('Hi, JPush')
    ->send();

echo 'Result=' . json_encode($result) . $br;

// 完整的推送示例,包含指定Platform,指定Alias,Tag,指定iOS,Android notification,指定Message等
$result = $client->push()
    ->setPlatform(array('ios', 'android'))
    ->addTag(array('tag1'))
    ->setMessage('2222')
    ->send();

echo 'Result=' . json_encode($result) . $br;


